package gui;

import java.util.GregorianCalendar;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DateTime;

/**
 * @author markus
 *
 */
public class YearlyPatternComposite extends Composite {

	/**
	 * 
	 */
	private DateTime date;
	/**
	 * @param parent parent composite
	 * @param style SWT-Style
	 */
	public YearlyPatternComposite(final Composite parent, final int style) {
		super(parent, style);
		FormLayout layout = new FormLayout();
		this.setLayout(layout);
		this.date = new DateTime(this, SWT.DROP_DOWN);
	}

	/**
	 * @return the date of this control
	 */
	public GregorianCalendar getDate() {
		return new GregorianCalendar(this.date.getYear(), this.date.getMonth(), this.date.getDay());
	}
	
	/**
	 * @param date input date
	 */
	public void setDate(final GregorianCalendar date) {
		this.date.setYear(date.get(GregorianCalendar.YEAR));
		this.date.setMonth(date.get(GregorianCalendar.MONTH));
		this.date.setDay(date.get(GregorianCalendar.DAY_OF_MONTH));
	}
	
	@Override
	public void setEnabled(final boolean b) {
		this.date.setEnabled(b);
	}
}
